<!-- 预览PDF -->
<script setup lang="ts">
import { ref } from 'vue'
import VuePdfEmbed from 'vue-pdf-embed'
const props = defineProps({
  /** 文件名 */
  fileName: String,
  /** 链接地址 */
  fileData: Blob,
  /** 渲染成功 */
  renderedHandler: Function,
  /** 渲染失败 */
  errorHandler: Function,
})
const pdfRef = ref<any>()
const currentPage = ref(null)
const currentRotation = ref(0)
// const showAllPages = ref(false);
const rotations = [0, 90, 180, 270]
</script>

<template>
  <vue-pdf-embed
    ref="pdfRef"
    class="h-full w-full container overflow-y-auto overflow-x-hidden"
    :rotation="rotations[currentRotation]"
    :page="currentPage"
    :source="props.fileData"
    @rendered="props.renderedHandler"
    @rendering-failed="props.errorHandler"
    @loading-failed="props.errorHandler"
  />
</template>

<style scoped>
.vue-pdf-embed {
  margin: 0 auto;
}
</style>
